package com.powerhua.core.base;

import com.powerhua.core.base.dao.DeleteDao;
import com.powerhua.core.base.dao.ListDao;
import com.powerhua.core.base.dao.ObjectDao;
import com.powerhua.core.base.dao.SaveDao;
import com.powerhua.core.base.dao.UpdateDao;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 *
 * @author Brian.Xie
 */
public class BaseManager {

    private static final Log LOG = LogFactory.getLog(BaseManager.class);
    private SaveDao saveDao;
    private UpdateDao updateDao;
    private DeleteDao deleteDao;
    private ListDao listDao;
    private ObjectDao objectDao;

    //------------------------------------------
    // Operater method
    //------------------------------------------
    /**
     * 
     * @param map
     * @param baseModelId
     * @return
     */
    public String save(Map map, String baseModelId) {
        return getSaveDao().save(map, baseModelId);
    }

    /**
     * 
     * @param map
     * @param baseModelId
     * @return
     */
    public String update(Map map, String baseModelId) {
        return getUpdateDao().update(map, baseModelId);
    }

    /**
     *
     * @param map
     * @param baseModelId
     * @return
     */
    public String delete(Map map, String baseModelId) {
        return getDeleteDao().delete(map, baseModelId);
    }

    /**
     * 
     * @param map
     * @param baseModelId
     * @return
     */
    public String list(Map map, String baseModelId, int pageSize, int pageNum) {
        return getListDao().list(map, baseModelId, pageSize, pageNum);
    }

    /**
     * 
     * @param map
     * @param baseModelId
     * @return
     */
    public String getObjectById(Map map, String baseModelId) {
        return getObjectDao().getObjById(map, baseModelId);
    }
    ////////////////////////////////
    // setter
    ////////////////////////////////
    /**
     * @param saveDao the saveDao to set
     */
    public void setSaveDao(SaveDao saveDao) {
        this.saveDao = saveDao;
    }

    /**
     * @param updateDao the updateDao to set
     */
    public void setUpdateDao(UpdateDao updateDao) {
        this.updateDao = updateDao;
    }

    /**
     * @param deleteDao the deleteDao to set
     */
    public void setDeleteDao(DeleteDao deleteDao) {
        this.deleteDao = deleteDao;
    }

    /**
     * @param listDao the listDao to set
     */
    public void setListDao(ListDao listDao) {
        this.listDao = listDao;
    }

    /**
     * 
     * @param objectDao
     */
    public void setObjectDao(ObjectDao objectDao) {
        this.objectDao = objectDao;
    }

    ///////////////////////////////
    // getter
    ///////////////////////////////
    public SaveDao getSaveDao() {
        return saveDao;
    }

    public UpdateDao getUpdateDao() {
        return updateDao;
    }

    public DeleteDao getDeleteDao() {
        return deleteDao;
    }

    public ListDao getListDao() {
        return listDao;
    }

    public ObjectDao getObjectDao() {
        return objectDao;
    }
}
